/*
 * Copyright 2021 Shulie Technology, Co.Ltd
 * Email: shulie@shulie.io
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.pamirs.tro.entity.dao.confcenter;

import java.util.List;
import java.util.Map;

import com.pamirs.tro.entity.domain.entity.TShadowTableDataSource;
import com.pamirs.tro.entity.domain.vo.TShadowTableConfigVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

/**
 * @author 298403
 * 影子表数据源配置
 */
@Mapper
public interface TShadowTableDataSourceDao {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    int deleteByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    int insert(TShadowTableDataSource record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    int insertSelective(TShadowTableDataSource record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    TShadowTableDataSource selectByPrimaryKey(Long id);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    int updateByPrimaryKeySelective(TShadowTableDataSource record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_shadow_table_datasource
     *
     * @mbggenerated
     */
    int updateByPrimaryKey(TShadowTableDataSource record);

    /**
     * 批量添加
     *
     * @param recordList
     * @return
     */
    int insertList(@Param("list") List<TShadowTableDataSource> recordList);

    /**
     * @param applicationId
     * @return
     */
    List<TShadowTableDataSource> queryShadowDataSourceByApplicationId(@Param("applicationId") Long applicationId);

    /**
     * 说明: 查询应用下的数据库服务的IP端口
     *
     * @param applicationId 应用ID
     * @param dbName        数据库名称
     * @return java.util.List<java.lang.String>
     * @author shulie
     * @create 2019/3/14 10:49
     */
    List<String> queryDatabaseIpPortList(@Param("applicationId") String applicationId, @Param("dbName") String dbName);

    /**
     * 说明: 查询应用下的数据库服务的库名
     *
     * @param applicationId 应用ID
     * @param ipPort        数据库的IP端口号
     * @return java.util.List<java.lang.String>
     * @author shulie
     * @create 2019/3/14 10:49
     */
    List<Map<String, Object>> queryDatabaseNameList(@Param("applicationId") String applicationId,
        @Param("ipPort") String ipPort);

    /**
     * 通过应用查询 数据源的IP端口和库名
     *
     * @param applicationId
     * @return
     */
    List<TShadowTableConfigVo> queryDatabaseIpPortAndName(@Param("applicationId") String applicationId);

    /**
     * 查询
     *
     * @param mapObject
     * @return
     */
    List<TShadowTableConfigVo> queryShadowDBApplicationList(Map mapObject);

    /**
     * 查询数据源ID
     *
     * @param applicationId
     * @param databaseName
     * @param ipPort
     * @return
     */
    Long queryShadowTableDatasourceId(@Param("applicationId") Long applicationId,
        @Param("databaseName") String databaseName, @Param("databaseIpPort") String ipPort);

    /**
     * 删除应用时删除数据源
     *
     * @param applicationIdList
     * @return
     */
    int deleteByApplicationIdList(@Param("applicationIdList") List<String> applicationIdList);

    /**
     * 获取有数据源配置  且使用影子表的 应用
     *
     * @return
     */
    List<Map<String, Object>> queryDatasourceApplicationdata(@Param("useShadowTable") String useShadowTable);
}
